package com.yunhe.job.client.fallback;

import com.yunhe.job.client.TaskClient;
import com.yunhe.common.model.ResultObject;
import com.yunhe.common.util.FallbackUtil;
import feign.hystrix.FallbackFactory;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Component;

import java.util.Map;

/**
 * @author liuronglei
 */
@Component
public class TaskFallbackFactory implements FallbackFactory<TaskClient> {
    @Override
    public TaskClient create(Throwable arg0) {
        return new TaskClient() {

            @Override
            public ResponseEntity<ResultObject> runTask(String taskUrl, Map<String, Object> map) {
                return FallbackUtil.getDefaultFallBack();
            }
        };
    }
}
